<?php
/**
 * 基础model
 * Date: 2025/08/31
 */

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

abstract class BaseModel extends Model
{
    /**
     * 使用软删除
     */
    use SoftDeletes;

    /**
     * 需要被转换日期时间格式的字段
     *
     * @var array
     */
    protected $dates = [
        'created_at',
        'updated_at',
        'deleted_at'
    ];

    /**
     * 转换日期时间格式为datetime
     *
     * @var array
     */
    protected $casts = [
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];

    /**
     * 统一序列化日期格式为 Y-m-d H:i:s
     */
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    /**
     * 通用STATUS（1：是，2：否）
     */
    const STATUS_OPEN = 1;
    const STATUS_CLOSE = 2;
}
